<?php
/**
 * Example for class DirectoryReader
 */
require_once "DirectoryReader.php";
/**
* example
*
* Example class for DirectoryReader
*
* @copyright Copyright (c) 2012 Maxim Bondarev
* @license http://www.opensource.org/licenses/mit-license.php
* @author Maxim Bondarev
* @version 1.0 
*/
class ExampleDir2 extends DirectoryReader
{
    public function showDirectory()
    {
        if ( NULL === $this->files ) {      
            throw new Exception( 'Empty list ' . $this->dir );
        }else {
            foreach ( $this->files as $key=>$file ) {           
                echo $file['name'] . '<br />' . PHP_EOL;        
            }
        }
    }
    
}

echo 
'<html>' . PHP_EOL .
'<head>' . PHP_EOL .
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />' . PHP_EOL .
'</head>' . PHP_EOL .
'<body>' . PHP_EOL .
"<h2>Search php at /usr/bin</h2>" . PHP_EOL;
    
try {
    $directory = new ExampleDir2( '/usr/bin' );        
    try {
        $directory->findItems( '/php/', $directory::DR_FILE );  
        $directory->showDirectory();
        echo  '<hr />Found ' . $directory->DirectoryItemsCount() . ' items' . PHP_EOL;
    }catch(Exception $e) {
        echo $e->getMessage();
    }

}catch(Exception $e) {
    echo $e->getMessage();
}